package com.lanjiu.lib.imclient.dto.chat;

import com.lanjiu.pro.business.BusinessProtocolEntities;
import com.lanjiu.lib.imclient.dto.base.Dto;

/**
 * @description: 文件
 * @author: Panwei
 * @date: 2019/11/14 21:19
 */
public class FileDto extends Dto {

    // 原文件下载URL
    private String url;

    // 当前坐标
    private long pos;

    // 当前文件内容大小
    private long length;

    public FileDto() {
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public long getPos() {
        return pos;
    }

    public void setPos(long pos) {
        this.pos = pos;
    }

    public long getLength() {
        return length;
    }

    public void setLength(long length) {
        this.length = length;
    }

    public FileDto(BusinessProtocolEntities.File file) {
        this.url = file.getUrl();
        this.pos = file.getPos();
        this.length = file.getLength();
    }

    @Override
    public BusinessProtocolEntities.File toProtobuf() {
        BusinessProtocolEntities.File.Builder builder = BusinessProtocolEntities.File.newBuilder();
        if (null != url) builder.setUrl(url);
        return builder.setPos(pos)
                .setLength(length)
                .build();
    }
}
